<?php
/**
 * Created by PhpStorm.
 * User: Dell
 * Date: 2019-4-10
 * Time: 9:28
 */

namespace app\index\controller;


use app\common\model\ArticleModel;
use think\Controller;

class Articles extends Controller
{
    public function index(){
        if(request()->isAjax()){

            $param = input('param.');

            $limit = $param['pageSize'];
            $offset = ($param['pageNumber'] - 1) * $limit;

            $where['delete'] = 0;
            $where['type'] = $param['type'];
            $article = new ArticleModel();


            $field = "title,description,thumbnail,content,add_time,type";
            $selectResult = $article->getArticlesByWhere($where, $offset, $limit,$field);

            foreach($selectResult as $key=>$vo){
                $selectResult[$key]['type'] = ['无','新闻资讯','故事鉴赏'][$selectResult[$key]['type']];
            }

            $return['total'] = $article->getAllArticles($where);  // 总数据
            $return['rows'] = $selectResult;

            return json($return);
        }
    }
}